// src/store/dashboardTabStore.ts

import { create } from 'zustand';

interface DashboardTabStore {
  currentTab: 'overview' | 'table';
  setTab: (tab: 'overview' | 'table') => void;
}

const getInitialTab = (): 'overview' | 'table' => {
  const saved = localStorage.getItem('dashboardTab');
  return saved === 'table' ? 'table' : 'overview';
};

export const useDashboardTabStore = create<DashboardTabStore>((set) => ({
  currentTab: getInitialTab(),
  setTab: (tab: 'overview' | 'table') => {
    localStorage.setItem('dashboardTab', tab);
    set({ currentTab: tab });
  },
})); 